package top.jle.jpa.basic.dao;

import jakarta.persistence.criteria.Predicate;
import jakarta.persistence.criteria.Root;
import org.hibernate.query.criteria.HibernateCriteriaBuilder;

import java.io.Serial;

public final class NotPreFilter implements PreFilter{
	

	@Serial
	private static final long serialVersionUID = -760708585474592826L;
	private final PreFilter preFilter;
	
	NotPreFilter(PreFilter preFilter){

		this.preFilter =preFilter;
	}


	/* (non-Javadoc)
	 * @see com.emin.eminview.base.dao.PreFilter#buildCriterion(org.hibernate.criterion.DetachedCriteria)
	 */
	@Override
	public <T> Predicate buildCriterion(Root<T> root, HibernateCriteriaBuilder builder) {
		
		return builder.not(preFilter.buildCriterion(root,builder));
	}

}
